package one.one.nine;

import java.util.Random;

public class Binary {

	static String toBinary(int a) {
		int l = (int) (Math.log(a) / Math.log(2));
		
		String r = "";
		for (int i = l; i >= 0; i--) {
			if (Math.pow(2, i) <= a) {
				a -= Math.pow(2, i);
				r += "1";
			}else {
				r+="0";
			}
		}
		return r;
	}

	public static void main(String[] args) {
		String s="";
		int N=10;
		for(int n=N;n>0;n/=2)
			s=(n%2)+s;
		System.out.println(s);
		/*
		int p;
		for(int i=0;i<10;i++) {
			p=new Random().nextInt(100);
			System.out.println(Integer.toBinaryString(p));
			System.out.println(toBinary(p));
			System.out.println(Integer.toBinaryString(p).equals(toBinary(p)));
		}
		*/
	}

}
